Name every setup handler initialize_x() - #117
Open
mikemaccana wants to merge 1 commit into
Open
Conversation
Bringing an account into existence had four names across these examples: init_ in lending, create_ in token-swap, order-book and betting-market, initialize_ in perpetual-futures, prop-amm and vault-strategy, and a bare initialize in the fundraiser. Two programs disagreed about the same concept: token-swap said create_config() where betting-market said initialize_config(). One rule now: if the domain has a word for it, use the domain's word; if the handler only stamps out a container, it is initialize_. So make_offer(), open_position(), place_order(), contribute() and refund() are untouched, because those verbs are what make the code read like finance, and add_x() still means extending a container that exists. Setup has no domain meaning, so it is always initialize_x(), naming what it initializes. Eight renames: init_lending_market, init_reserve, init_obligation, create_config, create_pool, create_market_user, create_event, and the fundraiser's bare initialize. Each carries its CamelCase account structs, its handle_ prefix, its test names and its source file. Verified: cargo check passes on all five renamed Anchor programs. Test crates need the Solana SBF toolchain to build their .so fixture and could not be compiled here, and the Quasar crates already fail to compile on a clean tree (4 to 12 errors each), so both want a CI run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BDUxWXgCA5TsoPPxHzRNen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bringing an account into existence had four names across these examples:
init_in lending,create_in token-swap, order-book and betting-market,initialize_in perpetual-futures, prop-amm and vault-strategy, and a bareinitializein the fundraiser. Two programs disagreed about the same concept: token-swap saidcreate_config()where betting-market saidinitialize_config().The rule
If the domain has a word for it, use the domain's word; if the handler only stamps out a container, it is
initialize_.Domain verbs are what make these programs read like finance, and they come in pairs, so
make_offer()/take_offer(),open_position()/close_position(),place_order()/cancel_order(),borrow,repay,liquidate,contributeandrefundare all untouched.add_x()still means extending a container that already exists, soadd_liquidity(),add_outcome()andadd_asset()are untouched too. Setup has no domain meaning, so it is alwaysinitialize_x(), naming what it initializes.The test is whether the handler moves money or takes a market action, or only writes parameters into a new account.
The renames
init_lending_marketinitialize_lending_marketinit_reserveinitialize_reserveinit_obligationinitialize_obligationcreate_configinitialize_configcreate_poolinitialize_poolcreate_market_userinitialize_market_usercreate_eventinitialize_eventinitializeinitialize_fundraiserEach carries its CamelCase account structs, its
handle_prefix, its test names, and its source file. No checked-in IDL contains any of these names, so nothing needs regenerating.Verification, and what is not verified
cargo checkpasses on all five renamed Anchor programs.include_bytes!a.sofixture that needscargo build-sbf, and this environment has no Solana toolchain. Call sites and test function names were renamed and grep-verified complete, but CI should confirm they build.Pairs with quicknode/solana-book#13, whose prose cites these handler names, and quicknode/solana-finance-claude-plugin#37, which records the rule.
Generated by Claude Code